package com.shuwei.wificollecttool;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Halohoop on 2017/11/21.
 */

public final class WifiDistributedNeedHolder {
    private volatile static WifiDistributedNeedHolder instance;

    /**
     * <mac, WifiHolder>
     */
    private Map<String, WifiHolder> wifiHolders;
    private long time;

    private WifiDistributedNeedHolder() {
        wifiHolders = new HashMap<>();
    }

    public static WifiDistributedNeedHolder getInstance() {
        if (instance == null) {
            synchronized (WifiDistributedNeedHolder.class) {
                if (instance == null) {
                    instance = new WifiDistributedNeedHolder();
                }
            }
        }
        return instance;
    }

    public void put(String mac, WifiHolder wifiItem) {
        wifiHolders.put(mac, wifiItem);
    }

    public Map<String, WifiHolder> getWifiHolders() {
        return wifiHolders;
    }

    public boolean contains(String mac) {
        return wifiHolders.containsKey(mac);
    }

    public void remove(String mac) {
        wifiHolders.remove(mac);
    }

    public int size() {
        return wifiHolders.size();
    }

    public void setTime(long l) {
        this.time = l;
    }

    public long getTime() {
        return time;
    }
}
